package com.fjut.kms.service;

import com.fjut.kms.dao.UserLicenseDao;
import com.fjut.kms.dao.UserLicenseJDBCImpl;
import com.fjut.kms.domain.UserLicense;

import java.util.List;

/**
 * Created by Empathy on 2017/8/2.
 */
public class UserLicenseServiceImpl implements UserLicenseService{
    public List<UserLicense> getUserLicense(String userName){
        UserLicenseDao ulDao=new UserLicenseJDBCImpl();
        return ulDao.getUserLicense(userName);

    }

    public boolean isActivated(String userName,String softNaem,String mac){
        UserLicense ul=null;
        UserLicenseDao ulDao=new UserLicenseJDBCImpl();
        /*List<UserActSoft> uasList=new ArrayList<UserActSoft>();
        UserActSoftDao uasDao=new UserActSoftJDBCImpl();
        uasList=uasDao.getByUserName(userName,softNaem,"");
        for (UserActSoft uas:uasList) {
            if ((!mac.equals(uas.getMac()))&&(!"".equals(uas.getStatus()))) return false;
        }*/
        ul=ulDao.getUserLicenseBySoftName(userName,softNaem);
        return (ul.getAssigned()>ul.getActivated())&&(ul!=null)?true:false;
    }
}
